#pragma once

#include "ColligereDatabaseLayoutBase.hpp"
#include "ColligereDatabaseHandlerBase.hpp"

namespace col {

class DatabaseInterfaceBase;

class DatabaseProperties
{
public:
	DatabaseProperties ( DatabaseInterfaceBase &rInterface );

	const wxString GetFullPath() const;
	const wxString GetHumanReadableFileSize() const;
	const wxString GetCreationTime() const;
	const wxString GetModificationTime() const;
	
	typedef std::map < const wxString, long > ItemCountMap;
	const ItemCountMap GetItemCounts();
private:
	DatabaseInterfaceBase &mrInterface;
	wxFileName mInFile;
};

/*! @brief A base class for a database interface.
 *
 * A database interface is a class which wraps the 
 * actual database layout and handler.
 **/
class DatabaseInterfaceBase : public boost::noncopyable
{
public:
	virtual void Open ( const wxString &rDbPath, wxAuiManager &rParentLayout ) = 0;
	virtual void Save ( const wxString &rNewDbPath = wxString() ) = 0;
	virtual bool Close() = 0;
	virtual bool IsOpened() const = 0;

	virtual DatabaseLayoutBase *GetLayout() = 0;
	virtual DatabaseHandlerBase *GetHandler() = 0;
	virtual const DatabaseLayoutBase *GetLayout() const = 0;
	virtual const DatabaseHandlerBase *GetHandler() const = 0;

	virtual const wxString GetStatusText ( wxUint32 statBarColumn ) const = 0;
	virtual const wxString GetTitleText() const = 0;

	// Dispatches frame GUI events (i.e. menu selection events) to the database layout.
	virtual void DispatchGuiEvent ( wxUint32 eventId ) = 0;

	//! Returns the ID of the database.
	virtual wxUint32 GetId() const = 0;

	virtual void Import ( const wxString &rFile ) = 0;

	virtual DatabaseProperties GetProperties() = 0;

	static DatabaseInterfaceBase *GetActive() { return mpsActiveInterface; }
protected:
	static void SetActive ( DatabaseInterfaceBase *pInterface ) { 
		mpsActiveInterface = pInterface; 
	}
private:
	static DatabaseInterfaceBase *mpsActiveInterface;
};

}